home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 November: Tool Chest / Dev.CD Nov 00 TC Disk 2.toast / pc / sample code / printing / scriptable print simpletext / aboutbox.c next >
Encoding:
C/C++ Source or Header  |  2000-09-28  |  4.2 KB  |  136 lines

  1. /*
  2. **    File:        AboutBox.c
  3. **
  4. **    Contains:    About Box support for SimpleText
  5. **
  6. ** Copyright 1993-1999 Apple Computer. All rights reserved.
  7. **
  8. **    You may incorporate this sample code into your applications without
  9. **    restriction, though the sample code has been provided "AS IS" and the
  10. **    responsibility for its operation is 100% yours.  However, what you are
  11. **    not permitted to do is to redistribute the source as "DSC Sample Code"
  12. **    after having made changes. If you're going to re-distribute the source,
  13. **    we require that you make it clear in the source that the code was
  14. **    descended from Apple Sample Code, but that you've made changes.
  15.  
  16. */
  17.  
  18. #include "MacIncludes.h"
  19.  
  20. #include "AboutBox.h"
  21.  
  22.  
  23. // --------------------------------------------------------------------------------------------------------------
  24. // INTERNAL ROUTINES
  25. // --------------------------------------------------------------------------------------------------------------
  26. static void DrawCenteredStringAt(Str255 theString, short yLocation)
  27. {
  28.     Rect    portRect = qd.thePort->portRect;
  29.     
  30.     MoveTo(portRect.left + ((portRect.right-portRect.left) >> 1) -
  31.                             (StringWidth(theString) >> 1), yLocation);
  32.     DrawString(theString);
  33.     
  34. } // DrawCenteredStringAt
  35.  
  36. // --------------------------------------------------------------------------------------------------------------
  37. // OOP INTERFACE ROUTINES
  38. // --------------------------------------------------------------------------------------------------------------
  39.  
  40. static OSErr    AboutUpdateWindow(WindowRef pWindow, WindowDataPtr pData)
  41. {
  42. #pragma unused (pData)
  43.  
  44.     Str255        theString;
  45.     
  46.     // type style for application name
  47.     TextFont(systemFont);
  48.     TextSize(12);
  49.     
  50.     // name of application
  51.     GetIndString(theString, kAboutStrings, 1);
  52.     DrawCenteredStringAt(theString, 32);
  53.     
  54.     // type style for all others
  55.     TextFont(applFont);
  56.     TextSize(9);
  57.     
  58.     // author names
  59.     GetIndString(theString, kAboutStrings, 2);
  60.     DrawCenteredStringAt(theString, 50);
  61.     GetIndString(theString, kAboutStrings, 3);
  62.     DrawCenteredStringAt(theString, 65);
  63.     GetIndString(theString, kAboutStrings, 4);
  64.     DrawCenteredStringAt(theString, 80);
  65.     
  66.     // copyright, on the left
  67.     GetIndString(theString, kAboutStrings, 5);
  68.     MoveTo(10, 105);
  69.     DrawString(theString);
  70.     
  71.     // version, on the right
  72.     GetIndString(theString, kAboutStrings, 6);
  73.     MoveTo((GetWindowPort(pWindow)->portRect.right - 10) - StringWidth(theString), 105);
  74.     DrawString(theString);
  75.     
  76.     return noErr;
  77.     
  78. } // AboutUpdateWindow
  79.  
  80. // --------------------------------------------------------------------------------------------------------------
  81.  
  82. static OSErr    AboutGetBalloon(WindowRef pWindow, WindowDataPtr pData, 
  83.         Point *localMouse, short * returnedBalloonIndex, Rect *returnedRectangle)
  84. {
  85. #pragma unused (pWindow, pData, localMouse, returnedRectangle)
  86.  
  87.     *returnedBalloonIndex = iNoBalloon;
  88.     
  89.     return noErr;
  90.     
  91. } // AboutGetBalloon
  92.  
  93. // --------------------------------------------------------------------------------------------------------------
  94.  
  95. static OSErr    AboutKeyEvent(WindowRef pWindow, WindowDataPtr pData, EventRecord *pEvent, Boolean isMotionKey)
  96. {
  97.     #pragma unused(pWindow, pData, pEvent, isMotionKey)
  98.  
  99.     return noErr;
  100.  
  101. } // AboutKeyEvent
  102.  
  103. // --------------------------------------------------------------------------------------------------------------
  104.  
  105. static OSErr    AboutMakeWindow(WindowRef pWindow, WindowDataPtr pData)
  106. {
  107. #pragma unused (pWindow)
  108.  
  109.     pData->pUpdateWindow = (UpdateWindowProc) AboutUpdateWindow;
  110.     pData->pGetBalloon     = (GetBalloonProc) AboutGetBalloon;
  111.     pData->pKeyEvent     = (KeyEventProc) AboutKeyEvent;
  112.  
  113.     return noErr;
  114.     
  115. } // AboutMakeWindow
  116.  
  117. // --------------------------------------------------------------------------------------------------------------
  118.  
  119. OSErr    AboutPreflightWindow(PreflightPtr pPreflightData)
  120. {
  121.     pPreflightData->resourceID             = kAboutWindowID;
  122.     pPreflightData->continueWithOpen     = true;
  123.     pPreflightData->makeProcPtr         = (MakeWindowProc) AboutMakeWindow;
  124.     
  125.     return noErr;
  126.     
  127. } // AboutPreflightWindow
  128.  
  129. // --------------------------------------------------------------------------------------------------------------
  130.  
  131. void AboutGetFileTypes(OSType * pFileTypes, OSType * pDocumentTypes, short * numTypes)
  132. {
  133. #pragma unused (pFileTypes, pDocumentTypes, numTypes)
  134.  
  135. } // AboutGetFileTypes
  136.